﻿//
// Decompiled with: Decompiler.NET, Version=1.3.1.18439, Culture=neutral, PublicKeyToken=null, Version: 1.3.1.18439
// Decompilation Started at: 3/15/2009 10:34:26 PM
// Copyright 2003 - 2004, Jungle Creatures, Inc., All Rights Reserved. 
// Written by Jonathan Pierce, Email: support@junglecreatures.com
//

namespace PatientManagement

{
		
		#region Namespace Import Declarations
		
			using System.ComponentModel;
			using System.Data.Common;
			using System.Data;
			using System.Data.SqlClient;
			using System.Drawing;
			using System;
			using System.Resources;
			using System.Windows.Forms;
			
		#endregion
		
	public class frmBANotCapThuoc : Form
	
	{
		
		#region Fields
			private BindingManagerBase bmb;
			private Button btExit;
			private Button btFirst;
			private Button btLast;
			private Button btSearch;
			public string CanNang;
			public string clr;
			public string clrISN;
			private IContainer components;
			private string connStr;
			private DataGrid dataGrid1;
			public string DiaChi;
			public string DienThoai;
			private DataSet ds;
			private DataSet dsStyle;
			public int flag;
			public string GioiTinh;
			public string HuyetAp;
			public string ID;
			public string ISN;
			private Label label1;
			private Label label2;
			private Label label3;
			public string Mach;
			public string NgaySinh;
			public string NgheNghiep;
			public string NhanBiet;
			public string NhietDo;
			public string patID;
			public string patName;
			private RadioButton rbAll;
			private RadioButton rbID;
			private RadioButton rbTenBenhNhan;
			private TextBox tbGoTo;
			private TextBox tbKeySearch;
			public string Ten;
			private ToolTip toolTip1;
			public string Tuoi;
		#endregion
		
		#region Constructors
		
			public frmBANotCapThuoc ()
			
			{
				this.flag = 1;
				this.InitializeComponent ();
				this.connStr = Connection.ConnectionString ();
				return;
			}
			
		#endregion
		
		#region Methods
		
			private void btExit_Click (object sender, EventArgs e)
			
			{
				base.Close ();
				return;
			}
			
			private void btFirst_Click (object sender, EventArgs e)
			
			{
				this.bmb.Position = 0;
				return;
			}
			
			private void btLast_Click (object sender, EventArgs e)
			
			{
				this.bmb.Position = (this.ds.Tables["vw_PatientHasPrescription"].Rows.Count - 1);
				return;
			}
			
			private void btSearch_Click (object sender, EventArgs e)
			
			{
				string theString;
				SqlConnection theSqlConnection;
				SqlDataAdapter theSqlDataAdapter;
				string[] theStringArray;
				theString = string.Empty;
				if (! this.rbAll.Checked)
				{
					goto L_0020;
				}
				this.frmTimHoSoBenhAn_Load (sender, e);
				goto L_0187;
				
			L_0020:
				
				{
				}
				if (this.tbKeySearch.Text != "")
				{
					goto L_004F;
				}
                DialogResult theDialogResult = MessageBox.Show("Vui lòng nhập từ khóa để tìm kiếm!", "Lỗi tìm kiếm", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0187;
				
			L_004F:
				
				{
				}
				theSqlConnection = new SqlConnection (this.connStr);
				if (! this.rbID.Checked)
				{
					goto L_008B;
				}
				theSqlDataAdapter = new SqlDataAdapter (string.Concat ("Select clrISN,patID,patName,patBirthdate,clrExaminationDate,clrExaminationDateVN"
				+ ",clrExaminationTimes,clrRexaminationTimes from  vw_PatientHasPrescription Where "
				+ "patID=\'", this.tbKeySearch.Text, "\'"), theSqlConnection);
				goto L_00C9;
				
			L_008B:
				
				{
				}
				theStringArray = new string[5];
				theStringArray[0] = "Select clrISN,patID,patName,patBirthdate,clrExaminationDate,clrExaminationDateVN"
				+ ",clrExaminationTimes,clrRexaminationTimes from  vw_PatientHasPrescription Where "
				+ "patisn in (SELECT patisn from patients where CONTAINS(patname,\'";
				theStringArray[1] = theString;
				theStringArray[2] = "\')  or patName like \'%";
				theStringArray[3] = this.tbKeySearch.Text;
				theStringArray[4] = "%\') ";
				theSqlDataAdapter = new SqlDataAdapter (string.Concat (theStringArray), theSqlConnection);
				
			L_00C9:
				
				{
				}
				this.dsStyle = new DataSet ();
				int i = theSqlDataAdapter.Fill (this.dsStyle, "vw_PatientHasPrescription");
				theSqlDataAdapter.Dispose ();
				theSqlConnection.Close ();
				if ((this.dsStyle != null) && ((this.dsStyle.Tables.Count != 0) && (this.dsStyle.Tables[0].Rows.Count != 0)))
				{
					goto L_013E;
				}
				
			L_0129:
				
				{
				}
				DialogResult theDialogResult2 = MessageBox.Show ("Không tìm thấy bệnh nhân ", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_0187;
				
			L_013E:
				
				{
				}
				this.dataGrid1.DataSource = this.dsStyle;
				this.dataGrid1.SetDataBinding (this.dsStyle, "vw_PatientHasPrescription");
				this.dataGrid1.ReadOnly = true;
				this.dataGrid1.TableStyles.Clear ();
				this.loadDataGrid ();
				
			L_0187:
				return;
			}
			
			private void dataGrid1_MouseUp (object sender, MouseEventArgs e)
			
			{
				frmCapThuoc theFrmCapThuoc;
				if (this.dataGrid1.DataSource == null)
				{
					goto L_00AE;
				}
				
			L_0012:
				
				{
				}
                if (MessageBox.Show("Bạn có muốn cấp thuốc của bệnh nhân này không?", "Xem hóa Đơn", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
				{
					goto L_00AE;
				}
				this.clrISN = this.dataGrid1[this.dataGrid1.CurrentRowIndex, 0].ToString ();
				this.patName = this.dataGrid1[this.dataGrid1.CurrentRowIndex, 2].ToString ();
				this.patID = this.dataGrid1[this.dataGrid1.CurrentRowIndex, 1].ToString ();
				theFrmCapThuoc = new frmCapThuoc (this);
				theFrmCapThuoc.ShowInTaskbar = false;
				DialogResult theDialogResult = theFrmCapThuoc.ShowDialog (((IWin32Window) this));
				this.frmTimHoSoBenhAn_Load (sender, ((EventArgs) e));
				
			L_00AE:
				return;
			}
			
			protected override void Dispose (bool disposing)
			
			{
				this.flag = 0;
				if (! disposing)
				{
					goto L_001D;
				}
				if (this.components == null)
				{
					goto L_001D;
				}
				this.components.Dispose ();
				
			L_001D:
				
				{
				}
				base.Dispose (disposing);
				return;
			}
			
			private void frmTimHoSoBenhAn_Load (object sender, EventArgs e)
			
			{
				SqlDataAdapter theSqlDataAdapter;
				theSqlDataAdapter = new SqlDataAdapter ("Select clrISN,patID,patName,patBirthdate,clrExaminationDate,clrExaminationDateVN"
				+ ",clrExaminationTimes,clrRexaminationTimes from  vw_PatientHasPrescription", this.connStr);
				this.ds = new DataSet ();
				int i = theSqlDataAdapter.Fill (this.ds, "vw_PatientHasPrescription");
				this.dataGrid1.TableStyles.Clear ();
				this.dataGrid1.DataSource = this.ds;
				this.dataGrid1.SetDataBinding (this.ds, "vw_PatientHasPrescription");
				this.loadDataGrid ();
				theSqlDataAdapter.Dispose ();
				return;
			}
			
			private void InitializeComponent ()
			
			{
				ResourceManager theResourceManager;
				Control[] theControlArray;
				this.components = ((IContainer) new System.ComponentModel.Container ());
				theResourceManager = new ResourceManager (typeof (frmBANotCapThuoc));
				this.label1 = new Label ();
				this.label2 = new Label ();
				this.rbID = new RadioButton ();
				this.rbTenBenhNhan = new RadioButton ();
				this.dataGrid1 = new DataGrid ();
				this.label3 = new Label ();
				this.tbKeySearch = new TextBox ();
				this.btSearch = new Button ();
				this.btExit = new Button ();
				this.rbAll = new RadioButton ();
				this.btFirst = new Button ();
				this.toolTip1 = new ToolTip (this.components);
				this.btLast = new Button ();
				this.tbGoTo = new TextBox ();
				((ISupportInitialize) this.dataGrid1).BeginInit ();
				base.SuspendLayout ();
				this.label1.Font = new System.Drawing.Font ("Verdana", 12F, FontStyle.Bold, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.label1.ForeColor = Color.MediumBlue;
				this.label1.Location = new Point (83, 24);
				this.label1.Name = "label1";
				this.label1.Size = new System.Drawing.Size (400, 23);
				this.label1.TabIndex = 0;
                this.label1.Text = "Danh sách Bệnh Nhân Chưa Cấp Thuốc";
				this.label1.TextAlign = ContentAlignment.MiddleCenter;
				this.label2.Location = new Point (104, 66);
				this.label2.Name = "label2";
				this.label2.Size = new System.Drawing.Size (72, 23);
				this.label2.TabIndex = 1;
				this.label2.Text = "Tìm theo:";
				this.rbID.Location = new Point (176, 64);
				this.rbID.Name = "rbID";
				this.rbID.TabIndex = 2;
				this.rbID.Text = "Số ID";
				this.rbTenBenhNhan.Location = new Point (248, 64);
				this.rbTenBenhNhan.Name = "rbTenBenhNhan";
				this.rbTenBenhNhan.Size = new System.Drawing.Size (128, 24);
				this.rbTenBenhNhan.TabIndex = 3;
				this.rbTenBenhNhan.Text = "Tên Bệnh Nhân";
				this.dataGrid1.AllowSorting = false;
				this.dataGrid1.BackgroundColor = SystemColors.ActiveCaptionText;
				this.dataGrid1.CaptionBackColor = SystemColors.ActiveCaptionText;
				this.dataGrid1.CaptionVisible = false;
				this.dataGrid1.DataMember = "";
				this.dataGrid1.HeaderForeColor = SystemColors.ControlText;
				this.dataGrid1.Location = new Point (16, 128);
				this.dataGrid1.Name = "dataGrid1";
				this.dataGrid1.ReadOnly = true;
				this.dataGrid1.Size = new System.Drawing.Size (648, 288);
				this.dataGrid1.TabIndex = 4;
				this.dataGrid1.MouseUp += new MouseEventHandler (this.dataGrid1_MouseUp);
				this.label3.Location = new Point (104, 98);
				this.label3.Name = "label3";
				this.label3.Size = new System.Drawing.Size (72, 23);
				this.label3.TabIndex = 5;
				this.label3.Text = "Từ khóa:";
				this.tbKeySearch.BorderStyle = BorderStyle.FixedSingle;
				this.tbKeySearch.Location = new Point (176, 96);
				this.tbKeySearch.Name = "tbKeySearch";
				this.tbKeySearch.Size = new System.Drawing.Size (184, 23);
				this.tbKeySearch.TabIndex = 6;
				this.tbKeySearch.Text = "";
				this.tbKeySearch.KeyPress += new KeyPressEventHandler (this.tbKeySearch_KeyPress);
				this.btSearch.FlatStyle = FlatStyle.Flat;
				this.btSearch.Location = new Point (368, 96);
				this.btSearch.Name = "btSearch";
				this.btSearch.TabIndex = 7;
				this.btSearch.Text = "Tìm";
				this.btSearch.Click += new EventHandler (this.btSearch_Click);
				this.btExit.FlatStyle = FlatStyle.Popup;
				this.btExit.Location = new Point (576, 424);
				this.btExit.Name = "btExit";
				this.btExit.Size = new System.Drawing.Size (88, 23);
				this.btExit.TabIndex = 8;
				this.btExit.Text = "Tho?t";
				this.btExit.Click += new EventHandler (this.btExit_Click);
				this.rbAll.Checked = true;
				this.rbAll.Location = new Point (384, 64);
				this.rbAll.Name = "rbAll";
				this.rbAll.TabIndex = 9;
				this.rbAll.TabStop = true;
				this.rbAll.Text = "Tất cả";
				this.btFirst.FlatStyle = FlatStyle.Popup;
				this.btFirst.Image = ((Image) ((Bitmap) theResourceManager.GetObject ("btFirst.Image")));
				this.btFirst.Location = new Point (16, 424);
				this.btFirst.Name = "btFirst";
				this.btFirst.Size = new System.Drawing.Size (24, 23);
				this.btFirst.TabIndex = 10;
                this.toolTip1.SetToolTip(((Control)this.btFirst), "Di chuyển đến mẫu tin đầu ti\x00ean");
				this.btFirst.Click += new EventHandler (this.btFirst_Click);
				this.btLast.FlatStyle = FlatStyle.Popup;
				this.btLast.Image = ((Image) ((Bitmap) theResourceManager.GetObject ("btLast.Image")));
				this.btLast.Location = new Point (120, 424);
				this.btLast.Name = "btLast";
				this.btLast.Size = new System.Drawing.Size (24, 23);
				this.btLast.TabIndex = 11;
                this.toolTip1.SetToolTip(((Control)this.btLast), "Di chuyển đến mẫu tin cuối c\x00f9ng");
				this.btLast.Click += new EventHandler (this.btLast_Click);
				this.tbGoTo.BorderStyle = BorderStyle.FixedSingle;
				this.tbGoTo.Location = new Point (48, 424);
				this.tbGoTo.Name = "tbGoTo";
				this.tbGoTo.Size = new System.Drawing.Size (64, 23);
				this.tbGoTo.TabIndex = 12;
				this.tbGoTo.Text = "";
				this.tbGoTo.TextChanged += new EventHandler (this.tbGoTo_TextChanged);
				this.AutoScaleBaseSize = new System.Drawing.Size (7, 16);
				base.ClientSize = new System.Drawing.Size (674, 459);
				theControlArray = new Control[13];
				theControlArray[0] = ((Control) this.tbGoTo);
				theControlArray[1] = ((Control) this.btLast);
				theControlArray[2] = ((Control) this.btFirst);
				theControlArray[3] = ((Control) this.rbAll);
				theControlArray[4] = ((Control) this.btExit);
				theControlArray[5] = ((Control) this.btSearch);
				theControlArray[6] = ((Control) this.tbKeySearch);
				theControlArray[7] = ((Control) this.label3);
				theControlArray[8] = ((Control) this.dataGrid1);
				theControlArray[9] = ((Control) this.rbTenBenhNhan);
				theControlArray[10] = ((Control) this.rbID);
				theControlArray[11] = ((Control) this.label2);
				theControlArray[12] = ((Control) this.label1);
				base.Controls.AddRange (theControlArray);
				this.Font = new System.Drawing.Font ("Verdana", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
				base.MaximizeBox = false;
				base.MinimizeBox = false;
				base.Name = "frmBANotCapThuoc";
				base.StartPosition = FormStartPosition.CenterScreen;
                this.Text = "Danh sách Bệnh Nhân Chưa Cấp Thuốc (Dược Sĩ)";
				base.TopMost = true;
				base.Load += new EventHandler (this.frmTimHoSoBenhAn_Load);
				((ISupportInitialize) this.dataGrid1).EndInit ();
				base.ResumeLayout (false);
				return;
			}
			
			public bool IsNumber (string Number)
			
			{
				bool theBoolean;
				
			L_0000:
				try
				{
					long theLong = long.Parse (Number);
					theBoolean = true;
				}
				catch
				{
					
				L_000B:
					
					{
					}
					theBoolean = false;
				}
				
			L_0010:
				
				{
				}
				return theBoolean;
			}
			
			public void loadDataGrid ()
			
			{
				DataGridTableStyle theDataGridTableStyle;
				DataGridTextBoxColumn theDataGridTextBoxColumn;
				DataGridTextBoxColumn theDataGridTextBoxColumn2;
				DataGridTextBoxColumn theDataGridTextBoxColumn3;
				DataGridTextBoxColumn theDataGridTextBoxColumn4;
				DataGridTextBoxColumn theDataGridTextBoxColumn5;
				DataGridTextBoxColumn theDataGridTextBoxColumn6;
				DataGridTextBoxColumn theDataGridTextBoxColumn7;
				theDataGridTableStyle = new DataGridTableStyle ();
				theDataGridTableStyle.MappingName = "vw_PatientHasPrescription";
				theDataGridTableStyle.AlternatingBackColor = Color.AliceBlue;
				theDataGridTableStyle.HeaderForeColor = Color.Maroon;
				theDataGridTableStyle.GridLineColor = Color.CornflowerBlue;
				theDataGridTextBoxColumn = new DataGridTextBoxColumn ();
				theDataGridTextBoxColumn.MappingName = "clrISN";
				theDataGridTextBoxColumn.HeaderText = "";
				theDataGridTextBoxColumn.Width = 0;
				int i = theDataGridTableStyle.GridColumnStyles.Add (((DataGridColumnStyle) theDataGridTextBoxColumn));
				theDataGridTextBoxColumn2 = new DataGridTextBoxColumn ();
				theDataGridTextBoxColumn2.MappingName = "patID";
				theDataGridTextBoxColumn2.HeaderText = "Số ID";
				theDataGridTextBoxColumn2.Width = 100;
				int i2 = theDataGridTableStyle.GridColumnStyles.Add (((DataGridColumnStyle) theDataGridTextBoxColumn2));
				theDataGridTextBoxColumn3 = new DataGridTextBoxColumn ();
				theDataGridTextBoxColumn3.MappingName = "patName";
                theDataGridTextBoxColumn3.HeaderText = "Tên Bệnh Nhân";
				theDataGridTextBoxColumn3.Width = 210;
				int i3 = theDataGridTableStyle.GridColumnStyles.Add (((DataGridColumnStyle) theDataGridTextBoxColumn3));
				theDataGridTextBoxColumn4 = new DataGridTextBoxColumn ();
				theDataGridTextBoxColumn4.MappingName = "patBirthDate";
                theDataGridTextBoxColumn4.HeaderText = "Ngày Sinh";
				theDataGridTextBoxColumn4.Width = 100;
				int i4 = theDataGridTableStyle.GridColumnStyles.Add (((DataGridColumnStyle) theDataGridTextBoxColumn4));
				theDataGridTextBoxColumn5 = new DataGridTextBoxColumn ();
				theDataGridTextBoxColumn5.MappingName = "clrExaminationTimesVN";
                theDataGridTextBoxColumn5.HeaderText = "Ngày Lập Bệnh Án";
				theDataGridTextBoxColumn5.Width = 140;
				theDataGridTextBoxColumn5.NullText = string.Empty;
				int i5 = theDataGridTableStyle.GridColumnStyles.Add (((DataGridColumnStyle) theDataGridTextBoxColumn5));
				theDataGridTextBoxColumn6 = new DataGridTextBoxColumn ();
				theDataGridTextBoxColumn6.MappingName = "clrExaminationTimes";
                theDataGridTextBoxColumn6.HeaderText = "Lần Khám";
				theDataGridTextBoxColumn6.Width = 120;
				theDataGridTextBoxColumn6.NullText = string.Empty;
				int i6 = theDataGridTableStyle.GridColumnStyles.Add (((DataGridColumnStyle) theDataGridTextBoxColumn6));
				theDataGridTextBoxColumn7 = new DataGridTextBoxColumn ();
				theDataGridTextBoxColumn7.MappingName = "clrRexaminationTimes";
                theDataGridTextBoxColumn7.HeaderText = "Lần Tái Khám";
				theDataGridTextBoxColumn7.Width = 120;
				theDataGridTextBoxColumn7.NullText = string.Empty;
				int i7 = theDataGridTableStyle.GridColumnStyles.Add (((DataGridColumnStyle) theDataGridTextBoxColumn7));
				int i8 = this.dataGrid1.TableStyles.Add (theDataGridTableStyle);
				theDataGridTableStyle.AllowSorting = false;
				this.bmb = this.BindingContext[this.dataGrid1.DataSource, this.dataGrid1.DataMember];
				return;
			}
			
			private void tbGoTo_TextChanged (object sender, EventArgs e)
			
			{
				int i;
				if (! this.IsNumber (this.tbGoTo.Text.ToString ()))
				{
					goto L_0094;
				}
				i = 0;
				goto L_0070;
				
			L_001C:
				
				{
				}
				if (this.ds.Tables["vw_PatientHasPrescription"].Rows[i][1].ToString () != this.tbGoTo.Text.ToString ())
				{
					goto L_006C;
				}
				this.bmb.Position = i;
				goto L_0092;
				
			L_006C:
				
				{
				}
				i++;
				
			L_0070:
				
				{
				}
				if (i < this.ds.Tables["vw_PatientHasPrescription"].Rows.Count)
				{
					goto L_001C;
				}
				
			L_0092:
				
				{
				}
				goto L_009F;
				
			L_0094:
				
				{
				}
				this.tbGoTo.SelectAll ();
				
			L_009F:
				return;
			}
			
			private void tbKeySearch_KeyPress (object sender, KeyPressEventArgs e)
			
			{
				if (e.KeyChar != '\r')
				{
					goto L_0012;
				}
				this.btSearch_Click (sender, ((EventArgs) e));
				
			L_0012:
				return;
			}
			
		#endregion
	}
	
}

